﻿#ifndef CONFIG_H
#define CONFIG_H

#include <QObject>
#include <QPointer>
#include <QRect>

struct UserBootConfig
{
    QString recordPath = "";
    quint32 bitRate = 2000000;
    int maxSizeIndex = 0;
    int recordFormatIndex = 0;
    int lockOrientationIndex = 0;
    bool recordScreen = false;
    bool recordBackground = false;
    bool reverseConnect = true;
    bool showFPS = false;
    bool windowOnTop = false;
    bool autoOffScreen = false;
    bool framelessWindow = false;
    bool keepAlive = false;
    bool simpleMode = false;
    bool autoUpdateDevice = true;
};

class QSettings;

class Config : public QObject
{
    Q_OBJECT

public:
    static Config &getInstance();

    QString getTitle(void);
    QString getServerVersion(void);
    int getMaxFps(void);
    int getDesktopOpenGL(void);
    int getSkin(void);
    int getRenderExpiredFrames(void);
    QString getPushFilePath(void);
    QString getServerPath(void);
    QString getAdbPath(void);
    QString getLogLevel(void);
    QString getCodecOptions(void);
    QString getCodecName(void);
    QStringList getConnectedGroups(void);

    void setUserBootConfig(const UserBootConfig & config);
    UserBootConfig getUserBootConfig(void);

    void setTrayMessageShown(bool shown);
    bool getTrayMessageShown(void);

    void setNickName(const QString &serial, const QString &name);
    QString getNickName(const QString & serial);

    void setRect(const QString & serial, const QRect & rc);
    QRect getRect(const QString & serial);

    void deleteGroup(const QString & serial);

private:
    explicit Config(QObject * parent = nullptr);
    const QString & getConfigPath(void);

private:
    static QString s_configPath;

    QPointer<QSettings> m_settings;
    QPointer<QSettings> m_userData;
};

#endif // CONFIG_H
